<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CheckLogIn</title>
<link href="UniversalStyleSheet.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="490" border="0" align="center" cellpadding="0" cellspacing="0">
<caption class="TableTitles">Log In
</caption>
  <tr>
    <td width="20" height="20" background="Images/TableUpperLeft.png">&nbsp;</td>
    <td height="20" background="Images/TableUpperMiddle.png">&nbsp;</td>
    <td width="20" height="20" background="Images/TableUpperRight.png">&nbsp;</td>
  </tr>
  <tr>
    <td width="20" background="Images/TableMiddleLeft.png">&nbsp;</td>
    <td align="center" valign="middle" bgcolor="#FFFFFF"><p id="msg">Validating User Name...Please Wait </p></td>
    <td width="20" background="Images/TableMiddleRight.png">&nbsp;</td>
  </tr>
  <tr>
    <td width="20" height="20" background="Images/TableLowerLeft.png">&nbsp;</td>
    <td height="20" background="Images/TableLowerMiddle.png">&nbsp;</td>
    <td width="20" height="20" background="Images/TableLowerRight.png">&nbsp;</td>
  </tr>
</table>
<%
Users=application("users")
ids=application("Uids")
UserList=split(users,"|")
idlist=split(ids,"|")

invalid=0
userAttempt=request.Form("UserName")
machineID=request.Cookies("HSmachineID")
if machineID="" then
	z=second(now())
	do until second(now())<>z
	loop
	machineID=hour(now()) & minute(now())&second(now())&day(now())&month(now())&year(now())
	
	response.Cookies("HSmachineID")=machineID
	response.Cookies("HSmachineID").expires=#1/1/2020#
	application.UnLock()
end if

for x=0 to ubound(UserList)
	if (userAttempt=UserList(x)) and (machineID<>idlist(x)) then 
		invalid=1
		exit for
	end if
next

if invalid=1 then
	%>
	<script type="text/javascript">
	var p=document.getElementById("msg")
	p.innerHTML="The User Name You Chose Is Already In Use. <br/> Please Choose Another User Name <br/><a href='LoginScreen.asp'><img src='Images/OKButton.png' border='0'></a>"
	</script>
	<%
else
	x=0
	idfound=0
	
	for x=0 to ubound(idlist)
		if userID=idlist(x) then 
			idfound=1
			matchpoint=x
			exit for
		end if
	next
	
	if idfound=0 then
		if application("users")="" then 
			application("users")=userAttempt
			application("Uids")=machineID
		else
			application("users")=application("users") & "|" & userAttempt
			application("Uids")=application("Uids") & "|" & machineID
		end if
		
		response.Cookies("HSuser")=userAttempt
	
	else
		UserList(matchpoint)=userAttempt
		for x=0 to ubound(UserList)
			temp=temp & UserList(x) & "|"
		next
		temp=left(temp,len(temp)-1)
		application("users")=temp
		response.Cookies("HSuser")=userAttempt
	end if
end if
'response.write(request.Cookies("HSuser"))
response.Redirect("search_panel.html")
%>
</body>
</html>
